Thanks everyone for your replies. The program does indeed require the filename specifically. I have someone else's software that downloads photos from flickr and stores them with a naming scheme that makes it possible to tell what the image's url was in flickr. Sometimes the downloaded file is 'empty' and so I wanted to make something that could open the image in Flickr in order to see what the image was.
Anyway, my first cpp application, albeit very simple:
Code:
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
using namespace std;
int main(int argc, char *argv[], char **envp)
{
string flickbase = "http://www.flickr.com/photos/";
const char* c_str();
if (argc == 1) {
cout << "No file specified." << endl;
} else {
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
_splitpath(argv[1], drive, dir, fname, ext);
string filename(fname);
string first_half = filename.substr(0, filename.find("-", 0));
string second_half = filename.substr(filename.find("-", 0)+1, filename.length());
string fullurl = flickbase + first_half + "/" + second_half;
cout << "Opening.." << fname << endl;
ShellExecute(NULL, "open", fullurl.c_str(), NULL, NULL, SW_SHOWNORMAL);
}
return 0;
}
I could have done this in perl, but I'm not trying to learn perl.